<?

/**
* Use $_SESSION["GDate"] if you are using custom date
* or just use the system date
*
* $today_date = $_SESSION["GDate"];
* $today_date = date("d-m-Y");
*
*/
$today_date		  = date("d-m-Y");

$thisSequence   = "MST_MODEL_SEQ";
$jobIdTag       = "12";

$srcDbHdr      = "MST_MODEL";
$srcDbDtl      = "MST_MODEL_COMPOS";
$srcDbHdrLog   = "LOG_MST_MODEL";
$srcDbSequence = "MST_SEQUENCE";

$UID     = unserialize($_SESSION["serUID"]);

$userId  = $UID->getUID();

$Db = new oracleDb;
$Db->init($_SESSION["ORCL"],
           $_SESSION["OPASS"],
           $_SESSION["SID"],
           _NO_COMMENT);

if($Db->connect()){

  $CLFetchers->fetchModelId($Db,
                            $_POST["modelEnt"],
                            $srcDbHdr,
                            $modelId);

	for($iRow = 0; $iRow < $dataup; $iRow++){

	  $CLFetchers->fetchModelId($Db,
                              $_POST["composEnt"][$iRow],
                              $srcDbHdr,
                              $composModelId);

	  $values = " '".$modelId."',               ".
	            "  ".($iRow + 1)." ,            ".
	            " '".$composModelId."',         ".
	            "  ".$_POST["qtyEnt"][$iRow]."  ";

	  $CLHandlers->insToDtl($Db,
	                        $values,
	                        $srcDbDtl);
	}

	$Db->commit();

	if($Db->getStatus()){

	  $Misc->usrMsg("Upload Complete");
	}else{

	  $Misc->usrDieJs("Upload Process Interupted");
	}

	$Db->dc();

	/**
	* Pending...
	* I'm not sure if this
	* reset procedure off
	* causes buggy
	*
	*	$restore  = 0;
	* $uprun    = 0;
	* $dataup   = 0;
	*
	*/

	//jumpTo(2,"../".$_SESSION["source_caller"]);

}else{

	$Misc->usrDieJs("Db connection failed");
}

?>